Skip to content

#221: a test for more lock waiters than the pool has threads - #222

Merged
EdmondDantes merged 1 commit into
mainfrom
221-flock-waiter-holds-a-thread
Aug 13, 2026
Merged

#221: a test for more lock waiters than the pool has threads#222
EdmondDantes merged 1 commit into
mainfrom
221-flock-waiter-holds-a-thread

Conversation

@EdmondDantes

@EdmondDantes EdmondDantes commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The regression test for #221. The engine side is merged:
true-async/php-src#18 landed on true-async, and true-async is merged into
true-async-stable, so this test now runs against a build that carries the fix.

Eight coroutines take one lock in turn with UV_THREADPOOL_SIZE=4, each holding it across
a suspension point so that the waiters really overlap. Against the thread-pool flock the
run never finishes — run-tests kills it on the timeout — because the holder's own write
needs a pool thread and the waiters have taken them all. With the fix the file ends up
with eight lines.

The test belongs here rather than in ext/standard/tests/file: it needs coroutines, and
what it pins is the async runtime's promise that waiting for a lock costs no thread.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@EdmondDantes
EdmondDantes force-pushed the 221-flock-waiter-holds-a-thread branch from ae809d5 to b4bee78 Compare August 12, 2026 21:18
Eight coroutines take one lock in turn with UV_THREADPOOL_SIZE=4, each holding it
across a suspension point so the waiters really overlap. Against the thread-pool
flock the run never finishes; the file ends up with eight lines instead.

The lock itself is checked, not only the deadlock: a waiter says so when flock()
returns false, and each compares the file size across its own suspension, so a lock
granted twice is reported rather than appended over. Removing the flock calls from
the body turns the test red — six of eight waiters see another writer.

081 described the locker as blocked in the thread pool, which is no longer where it
waits.
@EdmondDantes
EdmondDantes force-pushed the 221-flock-waiter-holds-a-thread branch from b4bee78 to 38c78e1 Compare August 13, 2026 05:21
@EdmondDantes
EdmondDantes merged commit 35fcac3 into main Aug 13, 2026
8 checks passed
@EdmondDantes
EdmondDantes deleted the 221-flock-waiter-holds-a-thread branch August 13, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant